package IO.g1;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.Date;

public class Serialization {


	public static void main(String[] args) throws FileNotFoundException, IOException, ClassNotFoundException {

		Student s = new Student("Horst",1234,"Informatik");
		Date date = new Date();
		
		ObjectOutputStream out = new ObjectOutputStream(
				new FileOutputStream("x.dat"));
		
		out.writeObject(date);
		out.writeObject(s);
		
		ObjectInputStream in = new ObjectInputStream(
				new FileInputStream("x.dat"));
		
		Date read = (Date)in.readObject();
		Student st = (Student)in.readObject();
		
		System.out.println(read);
		System.out.println(st.getName());
		

	}

}
